﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Template/Site_Main.Master" AutoEventWireup="true" CodeBehind="edu_backup.aspx.cs" Inherits="RegisterationSystem.Space_Education.edu_backup" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
<!--
        $(document).ready(function () {

            //            var LastBackupTime = $("#Cache_Hotel", window.top.document).attr("LastDBBakTime");
            //            if (LastBackupTime == "") {
            //                LastBackupTime = "无备份记录";
            //            }
            //            $("#LastBackupTime").html(LastBackupTime);
            // $("#LastBackupTime").html("2014-01-01");





            //初始化企业用户数据列表控件
////            $("#dataList").datagrid({
////                idField: "id",      //标识字段,主键
////                url: "../SyncService/GetDataList.ashx?action=getbakdblist",
////                // url: "../SyncService/GetDataList.ashx?action=getundistributedstulist",
////                //queryParams: { "where": "1=1", "typeid": "1" },
////                pagination: true,   //是否开启分页
////                rownumbers: true,   //行号
////                pageSize: 10,
////                pageNumber: 1,
////                columns: [[
////                            { field: 'name', title: '备份名', width: 120, align: 'center' },
////                            { field: 'time', title: '时间', width: 120, align: 'center' },
////                            { field: 'backup', title: '开始还原', width: 120, align: 'center', formatter: function (value, row) {
////                                return "<a href='javascript:void(0)' onclick=\"UpdStatus('" + row.id + "');\">开始还原</a>";
////                            }
////                        },
////                              { field: 'deletebackup', title: '删除此还原点', width: 120, align: 'center', formatter: function (value, row) {
////                                  return "<a href='javascript:void(0)' onclick=\"UpdStatus('" + row.id + "');\">删除此还原点</a>";
////                                }
////                             }
////                         ]]
////            });





            //            var dParam = "[{'HotelID':'" + 1810 + "'}]";
            //            var opt = {
            //                wcf: "BackupDatabase",
            //                way: "GetBakDBList",
            //                data: dParam,
            //                success: function (json) {
            //                    switch (json.result) {
            //                        case "Success":
            //                            $('#dataList').datagrid({
            //                                rownumbers: true,
            //                                //绑定主键
            //                                idField: "ID",
            //                                //只选择一行
            //                                singleSelect: true,
            //                                pageSize: 100,
            //                                //列定义与数据绑定
            //                                columns: [[
            //                                { field: 'Name', title: '备份名', width: 220 },
            //                                { field: 'Time', title: '时间', width: 140, align: 'center' }
            //                            ]]
            //                            });

            //                            $("#dataList").datagrid('loadData', json.rows);
            //                            break;
            //                    }
            //                }
            //            };
            //            $.base.post(opt);
        });


        function form_toBakup() {
//            alert("json.result");
        var dParam = "[{'HotelID':'" + 1810 + "'}]";
        var opt = {
            wcf: "BackupDatabase",
            way: "BakupDB1",
            data: dParam,
            success: function (json) {
                switch (json.result) {
                    case "Success11": 
                        $.messager.alert("确定", "数据备份成功，点击确定后程序将会重新加载", "info", function () {
                            top.location.reload();
                        });
                        break;
                    case "Failure":
                        $.messager.alert("错误", "数据备份失败，原因可能是权限不足", "error");
                        break;
                }
            }
        };
        $.messager.confirm("确定", "数据备份前请先确认已经完成其它所有工作，确定继续吗？", function (r) {
            if (r) { $.base.post(opt); }
        });
    }

    function form_toRestor() {
        var Row = $('#dataList').datagrid('getSelected');
        if (!Row) {
            $.messager.alert("错误", "请选择一个还原集", "error");
            return;
        }
        var BakFile = Row.Name;
        var dParam = "[{'HotelID':'" + $.base.hotelID() + "','BakFile':'" + BakFile + "'}]";
        var opt = {
            wcf: "BackupDatabase",
            way: "RestorDB",
            data: dParam,
            success: function (json) {
                switch (json.result) {
                    case "Success":
                        $.messager.alert("确定", "数据还原成功，如果程序不正常，请尝试刷新", "info");
                        break;
                    case "Failure":
                        $.messager.alert("错误", "数据还原失败，原因可能是权限不足", "error");
                        break;
                }
            }
        };
        $.messager.confirm("确定", "数据还原后可能会造成需要的数据丢失，确定继续吗？", function (r) {
            if (r) { $.base.post(opt); }
        });
    }
//-->
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Place_Local" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="loadheight">
<input type="hidden" id="hasConfig" value="" />
  <div class="clear_both" style="height:10px"></div>
  <label id="lb_headtitle">数据备份</label>
  <hr size="1" color="#2682AF" />
  <ul class="form_ul">
    <li class="form_li" style="width:400px;">
      <div class="div_text" style="padding-left:20px;">最近一次备份时间:<span id="backuptime" runat="server"></span></div>
      <div id="LastBackupTime" class="div_text" style=" color:#ff0000">...</div>
    </li>
    <li class="form_li">
      <div style="height:35px; padding-left:20px;">
        <a class="easyui-linkbutton" iconCls="icon-ok" href="javascript:void(0)" onclick="form_toBakup()">开始备份</a>
          <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="开始备份" />
      </div>
    </li>
  </ul>
  <div class="clear_both" style="height:20px"></div>
  <label id="lb_headtitle">数据还原</label>
  <hr size="1" color="#2682AF" />
  <ul class="form_ul">
    <li class="form_li" style="width:512.5px;">
      <table id="dataList"></table>
    </li>
  </ul>
  </div>
</asp:Content>
